import { alova } from '@/service/request';

/** get dbTable page */
export function paginateDbTable(params?: Api.SearchParams) {
  return alova.Get<Api.PageRow>('/dev/code/codeTable/dbTable/paginate', {
    params
  });
}

/** get CodeTable page */
export function paginateCodeTable(params?: Api.SearchParams) {
  return alova.Get<Api.PageRow>('/dev/code/codeTable/paginate', {
    params
  });
}

/** get all CodeTable */
export function listCodeTable() {
  return alova.Get<Api.Row[]>('/dev/code/codeTable/list');
}

/** create CodeGen */
export function getCodeTable(id?: number) {
  return alova.Get<Api.Dev.CodeGenRes>('/dev/code/codeTable/get', { params: { id }, hitSource: 'updateCodeTable' });
}

/** create CodeTable */
export function createCodeTable(data?: Api.Dev.CodeGenCreateReq) {
  return alova.Post<boolean>('/dev/code/codeTable/create', data);
}

/** update CodeTable */
export function updateCodeTable(data?: Api.Dev.CodeGenUpdateReq) {
  return alova.Post<boolean>('/dev/code/codeTable/update', data, { name: 'updateCodeTable' });
}

/** delete CodeTable */
export function deleteCodeTable(params: Api.DeleteParams) {
  return alova.Post<boolean>('/dev/code/codeTable/delete', undefined, { params });
}

/** delete CodeTable */
export function batchDelCodeTable(params: Api.BatchDeleteParams) {
  return alova.Post<boolean>('/dev/code/codeTable/batchDel', undefined, { params });
}

/** generate */
export function generateCodeTable(id: number) {
  return alova.Get<boolean>('/dev/code/codeTable/generate', { params: { id } });
}

/** download */
export function downloadCodeTable(id: number) {
  return alova.Get('/dev/code/codeTable/download', { params: { id } });
}

/** sync */
export function syncCodeTable(id: number) {
  return alova.Post<boolean>('/dev/code/codeTable/sync', { id });
}
